package com.lwx.test;

import java.util.Arrays;

public class TwoSumSolution {
    public static void main(String[] args) {
        int[] nums={3,2,3};
        int target = 6;
        int[] ret = twoSum(nums, target);
        System.out.println(Arrays.toString(ret));
    }


    public static int[] twoSum(int[] nums, int target) {

        if(nums != null && nums.length >= 2){
            int[] ret = new int[2];
            for (int i = 0; i < nums.length-1; i++) {
                for (int j = i+1; j < nums.length; j++) {
                    if(nums[i] + nums[j] == target){
                        ret[0] = i;
                        ret[1] = j;
                        return ret;
                    }
                }

            }
        }
        return null;
    }
}
